// // 把udp 消息转成joy

#include "udp/udp_server.hpp"

void CallBackFuntion(std::string ip, int port, std::vector<uint8_t> data, void *)
{
    printf("recv=[%s]:[%d]", ip.c_str(), port);
    // ROS_INFO("hhhai %d [", data.size());

    printf("data=%d [", data.size());
    for (size_t i = 0; i < data.size(); i++)
    {
        printf("%.2X ", data[i]);
    }
    printf("] \n");
}

using namespace std;
int main(int argc, char **argv)
{
    std::string iface = "::";
    int cliceport = -1;
    ADEALL_UDP_SERVER udp;

    switch (argc)
    {
    case 2:
        cliceport = stoi(argv[1]);
        break;
    case 3:
        cliceport = stoi(argv[1]);
        iface = argv[2];
        break;
    default:
        cout << "usage: " << argv[0] << "  <service/port> <hostname/ipaddress> " << endl;
        return -1;
        break;
    }

    if (udp.Init(cliceport, nullptr, iface, 2, CallBackFuntion) < 0)
    {
        return -1;
    }

    while (1)
    {
        sleep_ms(1);
    }

    return 0;
}
